import java.util.HashSet;
import java.util.Iterator;

public class Test {
    //随即链表的复制(深拷贝)
    /*public Node copyRandomList(Node head) {
        Map<Node,Node> map = new HashMap<>();
        //第一次便利使map集合里面存放相对应的键值对
        Node cur = head;
        while(cur != null){
            Node node = new Node(cur.val);
            //放入map集合里面，后续可以通过cur找到新的对应的node地址
            map.put(cur,node);
            cur = cur.next;
        }
        //再次进行遍历，整合对应的关系
        cur = head;
        while(cur != null){
            map.get(cur).next = map.get(cur.next);
            map.get(cur).random = map.get(cur.random);
            cur = cur.next;
        }
        return map.get(head);
    }*/
    public static int singleNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0;i<nums.length;i++){
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else{
                set.remove(nums[i]);
            }
        }
        Iterator<Integer> iterator = set.iterator();
        while(iterator.hasNext()){
            return iterator.next();
        }
        return -1;
    }
    public static void main(String[] args) {
        int[] array = {1,1,3,5,5,6,7,7,6};
        System.out.println(singleNumber(array));
    }
}
